<template>
  <div>
    <Chart :cdata="cdata" style="width: 900px" />
  </div>
</template>

<script>
import Chart from './chart.vue';
import {getNum} from "@/api/system/factory";

export function findMap(newData,cdata){
  const result = cdata.map(o => ({
    ...o,
    ...newData.find(n => n.name === o.name)
  }));
  return result
}
export default {
  data () {
    return {
      cdata: [
        {
          name: '呼和浩特市',

        },
        {
          name: '包头市',

        },
        {
          name: '乌海市',

        },
        {
          name: '赤峰市',

        },
        {
          name: '通辽市',

        },
        {
          name: '鄂尔多斯市',

        },
        {
          name: '呼伦贝尔市',

        },
        {
          name: '锡林郭勒盟',

        },
        {
          name: '阿拉善盟',

        },
        {
          name: '乌兰察布市',

        },
        {
          name: '兴安盟',

        },
        {
          name: '巴彦淖尔市',

        },
      ]
    }
  },
  components: {
    // CenterLeft2Chart,
    Chart,
  },
  mounted () {
    this.getData()
  },
  methods: {
    getData(){
      getNum().then(res=>{
        this.cdata = findMap(res,this.cdata)
        for (const resKey in this.cdata) {
          console.log(this.cdata[resKey].value)
        }
      })
    },

  }
}
</script>

<style lang="scss" scoped>
</style>
